<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<jsp:include page="../../include/top.jsp"/>
<div class="main_body">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li><a href="${BasePath}/app/student/list?${PublicParams}">学生列表<span class="arrow fa fa-sort-up"></span></a></li>
                <li class="current"><a href="">学生添加/修改<span class="arrow fa fa-sort-up"></span></a></li>
            </ul>
            <div class="tab-content">
                <div id="tab1" class="tab-pane in tab1">
                    <!-- 表单 -->
                    <form class="form-horizontal" id="myForm" name="myForm" action="${BasePath}/app/student/save" method="post">
                        <input type="hidden" name="id" value="${obj.id }"/>

                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                姓名：
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="name" id="name" value="${obj.name }">
                            </div>
                        </div>
                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                年龄：
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="age" id="age" value="${obj.age }">
                            </div>
                        </div>

                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                性别：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="sex" id="sex" value="${obj.sex }">
                            </div>
                        </div>
                        <div class="form-item cf">
                            <button class="btn submit-btn" id="submit" onclick="checkForm()" type="button">确 定</button>
                        </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
</div>
<script type="text/javascript">
    function checkForm() {
        var name = $("#name").val();
        if (name.trim() == "") {
            layer.msg('名字不能为空!', {icon: 5});
            return false;
        }
        var age = $("#age").val();
        if (age.trim() == "") {
            layer.msg('年龄不能为空!', {icon: 5});
            return false;
        }
        var sex = $("#sex").val();
        if (sex.trim() == "") {
            layer.msg('性别不能为空!', {icon: 5});
            return false;
        }

        $('#myForm').ajaxSubmit(function (data) {
            if (data.errno == 1) {
                layer.msg(data.errdesc, {icon: 5});
            } else {
                layer.msg('操作成功！');
               // alert(${PublicParams});
                window.location.href = "${BasePath}/app/student/list?${PublicParams}";
            }
        });
    }
</script>
<jsp:include page="../../include/bottom.jsp"/>
